#ifndef __RENDERER_GLES_COMPILE_CONFIG_H__
#define __RENDERER_GLES_COMPILE_CONFIG_H__

#pragma once

#ifdef NEZHA_GLES_EXPORT

#		define NEZHA_GLES_ENTRY __declspec(dllexport)

#else

#	ifdef NEZHA_GLES_DLLIMPORT

#		define NEZHA_GLES_ENTRY __declspec(dllimport)

#	else

#		define NEZHA_GLES_ENTRY

# endif

#endif //end NEZHA_GLES_EXPORT

#include "NezhaEngine.h"
#include "Rendering/Renderer.h"

#ifdef NZOS_IOS
#include <OpenGLES/ES1/gl.h>
#include <OpenGLES/ES1/glext.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#else
#include "GLES2/gl2.h"
#endif

namespace Nezha
{

	class NEZHA_GLES_ENTRY GLenumMapping
	{
	public:
		static GLenum BufferUsage(u32 usage);

		static GLenum VertexAttrib(u32 va);

		static GLenum GeometryDataType(u32 gdt);

		static GLenum GLFillMode(RS_FillMode fm);

		static GLenum GLCompareFunc(RS_CmpMode cmp);

		static GLenum GLStencilOp(RS_StencilOP rsop, bool invert);

		static GLenum GLBlendFactor(BlendFactor bf);

		static GLenum GLBlendOp(BlendOperation op);

		static ShaderParamDataType ShaderParamType(GLenum glType);

		static GLenum GLTexFormat(TexFormat tf);

		static GLenum GLTexWrap(ShaderSampler::WrapMode wm);

		static GLenum GLTexFilter(ShaderSampler::Filter sf);
	};

}//end namespace Nezha

#pragma warning( disable : 4275 )
#pragma warning( disable : 4251 )

// remarks, disable this for final release, because this really expensive.
#ifdef NEZHA_OPENGL_ERROR_CHECK

#	define GL_ERROR_DUMP(ada) {GLESAdaptor::msErrorFileName=__FILE__;GLESAdaptor::msErrorLine=__LINE__;(ada)->checkGLError();}
#	define IMPL_ERROR_DUMP(ada) {GLESAdaptor::msErrorFileName=__FILE__;GLESAdaptor::msErrorLine=__LINE__;(ada)->checkImplError();}

#else

#	define GL_ERROR_DUMP(ada)
#	define IMPL_ERROR_DUMP(ada)

#endif

#define TEST_ERROR_OWNSHIP(ada) ((ada)->getErrorOwner() == ((void*)this))

#define VBO_BUFFER_OFFSET(i) ((char *)NULL + (i))

#endif //end __RENDERER_GLES_COMPILE_CONFIG_H__